package com.juvepoland.jpdroid.models;

import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Comment {
	
	public static final String D_ID				="id";
	public static final String D_CONTENT		="content";
	public static final String D_USER_ID		="uid";
	public static final String D_NEWS_ID		="nid";
	public static final String D_DATE			="unixtime";
	public static final String D_G_ID			="gid";

	
	private int id;
	private User user;
	private News news;
	private Date date;
	private String ip;
	private String content;
	private NewsType newsType;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public News getNews() {
		return news;
	}
	public void setNews(News news) {
		this.news = news;
	}
	public Date getDate() {
		return date;
	}
	public long getDateLong(){
		return new Date().getTime()/1000;
	}
	public String getStringDate(){
		 Format formatter = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
		 return formatter.format(getDate());
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public void setDate(long timestamp){
		Date d = new Date();
		timestamp = timestamp*1000;
		d.setTime(timestamp);
		this.setDate(d);
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public NewsType getNewsType() {
		return newsType;
	}
	public void setNewsType(NewsType newsType) {
		this.newsType = newsType;
	}
		
	@Override
	public String toString() {
		return "ID: "+getId()+"; Content: "+getContent()+"; UserID:"+getUser().getId()+"; unixtime: "+getDateLong()+
				"; News ID:"+getNews().getId()+"; Gid: "+getNewsType().getCode();
	}
	
	

}
